package cn.school.thoughtworks.section2;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

public class PracticeA {
    Map<String,Integer> countSameElements(List<String> collection1) {
        //实现练习要求，并改写该行代码。
        Map<String,Integer> sameElement=new HashMap<String,Integer>();
        for(int i=0;i<collection1.size();i++){
            Integer sum=sameElement.get(collection1.get(i));
            sameElement.put(collection1.get(i), sum==null?1:sum+1);
        }
        return sameElement;
    }
}
